from abc import ABCMeta, abstractmethod


class Broadcaster(object):
    
    def __init__(self):
        self.listeners = set()

    def register(self, listener):
        self.listeners.add(listener)

    def unregister(self, listener):
        self.listeners.remove(listener)

    def broadcast_event(self, event):
        for l in self.listeners:
            l.listen(self, event)


class Listener(object):
    
    __metaclass__ = ABCMeta
    
    @abstractmethod
    def listen(self, broadcaster, event):
        pass
